﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Maticsoft.DBUtility;
namespace SkWeb.FASJ
{
    public partial class bookMarkHander : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string result = "{\"success\":true}";
            string str = Request.QueryString["action"];
            if (str.ToLower() == "add")
            {
               string name=  Request.Form["name"];
               string text = Request.Form["text"];
               string field_name = Request.Form["field_name"];
               string default_varl = Request.Form["default_varl"];
               string multi_val = Request.Form["multi_val"];
               string formula = Request.Form["formula"];
               string sh=Request.Form["xh"];
                string xs=Request.Form["xs"]=="on"?"1":"0";
               string strSql = "insert into tb_bookmark1(name,text,field_name,default_varl,multi_val,formula,xh,xs) values('" + name + "','" + text + "','" + field_name + "','" + default_varl + "','" + multi_val + "','" + formula + "',"+sh+","+xs+")";
               if (DbHelperOra.ExecuteSql(strSql) != 1)
               {
                   result = string.Concat("{\"success\":false, \"msg\":\"", "插入出错，请联系管理员", "\"}");
               }
            }
            else if (str.ToLower() == "update")
            {
                string name = Request.Form["name"];
                string text = Request.Form["text"];
                string field_name = Request.Form["field_name"];
                string default_varl = Request.Form["default_varl"];
                string multi_val = Request.Form["multi_val"];
                string formula = Request.Form["formula"];
                string sh=Request.Form["xh"];
                string xs=Request.Form["xs"]=="on"?"1":"0";
                string strSql;
                if (string.IsNullOrEmpty(sh))
                {
                     strSql = "update tb_bookmark1 set text = '" + text + "',field_name='" + field_name + "', default_varl='" + default_varl + "' , multi_val='" + multi_val + "',formula='" + formula + "',xs=" + xs + "  where name = '" + name + "'";
                }
                else
                {
                     strSql = "update tb_bookmark1 set text = '" + text + "',field_name='" + field_name + "', default_varl='" + default_varl + "' , multi_val='" + multi_val + "',formula='" + formula + "',xh=" + sh + ",xs=" + xs + "  where name = '" + name + "'";
                }
               
                if (DbHelperOra.ExecuteSql(strSql) != 1)
                {
                    result = string.Concat("{\"success\":false, \"msg\":\"", "插入出错，请联系管理员", "\"}");
                }
            }

            Response.ContentType = "text/plain";
            Response.Write(result);
            Response.End();

        }



    }
}